function showAdd() {
    goodsChange();
    $("#myModal").modal("show");
}

function delSell(id) {
    if (confirm("确定删除吗？")) {
        $.post("/sell/del", {id: id}, function (nm) {
            if (nm.ok) {
                window.location.href = "/sell";
            }
        })
    }
}

function goodsChange() {
    var id = $("#goodsId").val();
    $.get("/goods/getById?id=" + id, function (goods) {
        $("#stock").val(goods.stock);
        $("#outPrice").val(goods.outPrice);
    })
}

function saveSell() {
    var _count = $("#count");
    var _stock = parseInt($("#stock").val());
    var _countVal = parseInt(_count.val());
    if (_countVal > _stock) {
        _count.focus();
        new $.zui.Messager('库存不足！', {
            icon: 'bell',
            placement: 'bottom-right'
        }).show();
        return;
    }
    $("#sellForm").submit();
}